<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./jquery-3.4.1.js"></script>
</head>

<body>
    <li>li1</li>
    <li>li2</li>
    <li>li3</li>
    <script>
        console.log($("li"));

        /* 001-jQ.toArray()  把jQuery对象转换为真正的数组 */
        console.log($("li").toArray());

        /* 002-$.makeArray() 把伪数组(jQuery)转换为数组*/
        let likeArr = {
            0: "name",
            1: "zge",
            2: "address",
            length: 3
        };
        console.log($.makeArray($("li")));
        console.log(likeArr);
        console.log($.makeArray(likeArr));

        /* 003-$.trim 清理字符串前面和后面的N个空格 */
        console.log($.trim("  adsad sdfdsf    "));

        /* 004-合并数组 */
        console.log($.merge([1, 2, 3, 4], [10, 20, 30]));

        /* 005-把对象转换为查询字符串*/
        let o = {
            name: "zs",
            age: 19,
            className: "h5"
        };
        /* name=zs&age=19&className=h5 */
        // let arr = [];
        // for (let key in o) {
        //     arr.push(`${key}=${o[key]}`);
        // }
        // let res = arr.join("&");
        // console.log(res); /* name=zs&age=19&className=h5 */
        console.log($.param(o), "+"); /* name=zs&age=19&className=h5 + */

        /* 006-$.isEmptyObject(obj) 检查指定的对象是否是空对象 */
        console.log($.isEmptyObject({}), $.isEmptyObject(o));

        /* 007-$.type 检查对象的类型 */
        /* 核心代码：Object.prototype.toString.call([]) == [object Array] */
        console.log($.type(123), $.type("string"), $.type(function() {}), $.type([]), $.type(/abc/));
    </script>
</body>

</html>